import {createRouter, createWebHistory} from "vue-router";
import HomeView from "../views/HomeView.vue";
import AboutView from "../views/AboutView.vue";
import BlogDetailView from "../views/BlogDetailView.vue";
import CreateEditBlogView from "../views/CreateEditBlogView.vue";
import LoginView from "../views/LoginView.vue";
import MylogsView from "../views/MylogsView.vue";
import RegisterView from "../views/RegisterView.vue";

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        // 主页
        {
            path: "/",
            name: "home",
            component: HomeView
        },
        // 关于我们页面
        {
            path: "/about",
            name: "about",
            component: AboutView
        },
        // 博客详情页面
        {
            path: "/blog/:id",
            name: "blogDetail",
            component: BlogDetailView,
            props: true // 如果你需要将参数直接传递给组件作为props
        },
        // 创建或编辑博客页面
        {
            path: "/create",
            name: "saveBlog",
            component: CreateEditBlogView
        },
        // 登录页面
        {
            path: "/login",
            name: "login",
            component: LoginView
        },
        // 我的日志页面
        {
            path: "/mylogs",
            name: "mylogs",
            component: MylogsView
        },
        // 注册页面
        {
            path: "/register",
            name: "register",
            component: RegisterView
        },
    ],
});

export default router;
